package com.cyt.web.controller.work.site;

import cn.hutool.core.util.StrUtil;
import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.BaseConstant;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import com.cyt.work.site.model.vo.SchoolVo;
import com.cyt.work.site.service.SchoolService;
import com.cyt.wx.model.po.WxApply;
import com.cyt.wx.service.WxApplyService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 微官网-学校简介控制层
 *
 * @author rong yuan
 * @date 2019-7-8 18:37:06
 */
@RestController
public class SchoolController extends BaseController {

    @Resource
    private SchoolService schoolService;

    /**
     * 统一跳转
     *
     * @param pageName 页面名称
     * @param applyId 应用id
     * @return ModelAndView
     * @author shengQiang Yu
     * @date 2019-08-28 15:17:40
     */
    @RequestMapping("/work/site/school/{pageName}")
    public ModelAndView goPage(@PathVariable("pageName") String pageName,String applyId) {
        ModelAndView view = new ModelAndView("/work/site/school/"+pageName);
        view.addObject("applyId",applyId);
        return view;
    }

    /**
     * 查询对象
     *
     * @param request  请求对象
     * @param schoolVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2019-7-8 18:37:06
     */
    @BaseLog(module = "微官网", classz = "学校简介", methods = "查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/site/school/select", method = RequestMethod.POST)
    public ReturnResult select(HttpServletRequest request, SchoolVo schoolVo) {
        return new ReturnResult(schoolService.selectSchool(schoolVo));
    }

    /**
     * 保存或更新
     *
     * @param request  请求对象
     * @param schoolVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2019-7-8 18:37:06
     */
    @BaseLog(module = "微官网", classz = "学校简介", methods = "保存或更新对象", businessType = BusinessType.INSERT, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/work/site/school/addOrUpdate", method = RequestMethod.POST)
    public ReturnResult addOrUpdate(HttpServletRequest request, SchoolVo schoolVo) {
        return schoolService.addOrUpdate(schoolVo, acceptCurrentUser(request));
    }
}